<template>
    <input type="text" v-model="val">
    <button @click="handleAdd">点击</button>
</template>
<script setup>
import { ref, defineEmits } from "vue"

//声明自定义事件 完成子传父

let val = ref("")

let emit = defineEmits(['add'])

let handleAdd = () => {
    emit('add', val.value)
}

</script>